<template>
  <el-select
    style="width: 100%"
    :disabled="item.disabled"
    :placeholder="getPlaceholder('请输入')"
    v-model="model"
    :allow-create="item.allowCreate || true"
    :filterable="item.filterable || false"
    :default-first-option="item.defaultFirstOption || true"
    :clearable="item.clearable || true"
    @change="handleChange"
    :multiple="item.multiple || false"
    :collapse-tags="item.collapseTags || false"
  >
    <el-option
      v-for="it in item.optionsList"
      :key="it[item.valueKey || 'id']"
      :label="it[item.labelKey || 'label']"
      :value="it[item.valueKey || 'id']"
    >
      <div class="option">
        <div class="text">
          <div class="label">{{ it[item.labelKey || "label"] }}</div>
          <div class="extra" v-if="it[item.extraKey || 'extra']">
            {{ it[item.extraKey || "extra"] }}
          </div>
        </div>
        <div class="remark" v-if="it[item.remarkKey || 'remark']">
          {{ it[item.remarkKey || "remark"] }}
        </div>
      </div>
    </el-option>
  </el-select>
</template>

<script>
import yDefault from "./y-default.vue";
export default {
  includesComponent: ["select"],
  name: "y-select",
  extends: yDefault,
};
</script>

<style lang="scss" scoped>
.option {
  .text {
    display: flex;
    justify-content: space-between;
    align-items: center;
    .label {
      color: #333;
      font-size: 16px;
    }
    .extra {
      color: #8492a6;
      font-size: 13px;
      line-height: 13px;
    }
  }
  .remark {
    color: #8492a6;
    font-size: 13px;
    line-height: 13px;
    padding-bottom: 10px;
  }
}
.el-select-dropdown__item {
  height: auto;
}
</style>
